﻿using System;
using System.Runtime.InteropServices;
using UnityEngine;

namespace Manager
{
	// Token: 0x020004D6 RID: 1238
	public class GameCursor : Singleton<GameCursor>
	{
		// Token: 0x17000394 RID: 916
		// (get) Token: 0x06001F7D RID: 8061 RVA: 0x000C3B6C File Offset: 0x000C1D6C
		// (set) Token: 0x06001F7E RID: 8062 RVA: 0x000C3B74 File Offset: 0x000C1D74
		public static bool isDraw
		{
			get
			{
				return Cursor.visible;
			}
			set
			{
				Cursor.visible = value;
			}
		}

		// Token: 0x17000395 RID: 917
		// (get) Token: 0x06001F7F RID: 8063 RVA: 0x000C3B7C File Offset: 0x000C1D7C
		// (set) Token: 0x06001F80 RID: 8064 RVA: 0x000C3B84 File Offset: 0x000C1D84
		public static bool MouseLocked
		{
			get
			{
				return GameCursor.mouseLocked;
			}
			set
			{
				GameCursor.mouseLocked = value;
				Cursor.visible = !value;
				Cursor.lockState = ((!Cursor.visible) ? CursorLockMode.Locked : CursorLockMode.None);
			}
		}

		// Token: 0x17000396 RID: 918
		// (get) Token: 0x06001F81 RID: 8065 RVA: 0x000C3BAC File Offset: 0x000C1DAC
		// (set) Token: 0x06001F82 RID: 8066 RVA: 0x000C3BB4 File Offset: 0x000C1DB4
		public GameCursor.CursorKind kindCursor { get; private set; }

		// Token: 0x06001F83 RID: 8067 RVA: 0x000C3BC0 File Offset: 0x000C1DC0
		private void Start()
		{
			GameCursor.pos = Input.mousePosition;
			GameCursor.GetCursorPos(out this.lockPos);
			this.windowPtr = GameCursor.GetForegroundWindow();
		}

		// Token: 0x06001F84 RID: 8068 RVA: 0x000C3BE4 File Offset: 0x000C1DE4
		private void Update()
		{
			if (GameCursor.isLock)
			{
				GameCursor.SetCursorPos(this.lockPos.X, this.lockPos.Y);
				return;
			}
			GameCursor.pos = Input.mousePosition;
			GameCursor.GetCursorPos(out this.lockPos);
		}

		// Token: 0x06001F85 RID: 8069 RVA: 0x000C3C24 File Offset: 0x000C1E24
		public bool setCursor(GameCursor.CursorKind _eKind, Vector2 _vHotSpot)
		{
			Texture2D texture = null;
			if (_eKind == GameCursor.CursorKind.Spanking)
			{
				texture = this.atexChange[(int)_eKind];
			}
			Cursor.SetCursor(texture, _vHotSpot, CursorMode.ForceSoftware);
			this.kindCursor = _eKind;
			return true;
		}

		// Token: 0x06001F86 RID: 8070
		[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
		private static extern void SetCursorPos(int X, int Y);

		// Token: 0x06001F87 RID: 8071
		[DllImport("USER32.dll")]
		[return: MarshalAs(UnmanagedType.Bool)]
		private static extern bool GetCursorPos(out GameCursor.POINT lpPoint);

		// Token: 0x06001F88 RID: 8072
		[DllImport("USER32.dll")]
		private static extern bool ScreenToClient(IntPtr hWnd, ref GameCursor.POINT lpPoint);

		// Token: 0x06001F89 RID: 8073
		[DllImport("USER32.dll")]
		private static extern bool ClientToScreen(IntPtr hWnd, ref GameCursor.POINT lpPoint);

		// Token: 0x06001F8A RID: 8074
		[DllImport("USER32.dll", CallingConvention = CallingConvention.StdCall)]
		private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

		// Token: 0x06001F8B RID: 8075
		[DllImport("user32.dll")]
		private static extern int MoveWindow(IntPtr hwnd, int x, int y, int nWidth, int nHeight, int bRepaint);

		// Token: 0x06001F8C RID: 8076
		[DllImport("user32.dll")]
		private static extern int GetWindowRect(IntPtr hwnd, ref GameCursor.RECT lpRect);

		// Token: 0x06001F8D RID: 8077
		[DllImport("user32.dll")]
		private static extern IntPtr GetForegroundWindow();

		// Token: 0x06001F8E RID: 8078
		[DllImport("user32.dll")]
		private static extern IntPtr FindWindow(string className, string windowName);

		// Token: 0x06001F8F RID: 8079
		[DllImport("user32.dll")]
		public static extern bool SetWindowText(IntPtr hwnd, string lpString);

		// Token: 0x06001F90 RID: 8080 RVA: 0x000C3C64 File Offset: 0x000C1E64
		public void SetCoursorPosition(Vector3 mousePos)
		{
			GameCursor.POINT point = new GameCursor.POINT(0, 0);
			GameCursor.ClientToScreen(this.windowPtr, ref point);
			GameCursor.GetWindowRect(this.windowPtr, ref this.winRect);
			GameCursor.POINT point2 = new GameCursor.POINT(point.X - this.winRect.left, point.Y - this.winRect.top);
			point.X = (int)mousePos.x;
			point.Y = Screen.height - (int)mousePos.y;
			GameCursor.ClientToScreen(this.windowPtr, ref point);
			GameCursor.SetCursorPos(point.X + point2.X, point.Y + point2.Y);
		}

		// Token: 0x06001F91 RID: 8081 RVA: 0x000C3D1C File Offset: 0x000C1F1C
		public void SetCursorLock(bool setLockFlag)
		{
			if (setLockFlag)
			{
				if (!GameCursor.isLock)
				{
					GameCursor.GetCursorPos(out this.lockPos);
					GameCursor.isLock = true;
					Cursor.visible = false;
				}
			}
			else if (GameCursor.isLock)
			{
				GameCursor.SetCursorPos(this.lockPos.X, this.lockPos.Y);
				GameCursor.isLock = false;
				Cursor.visible = true;
			}
		}

		// Token: 0x06001F92 RID: 8082 RVA: 0x000C3D88 File Offset: 0x000C1F88
		public void UnLockCursor()
		{
			if (GameCursor.isLock)
			{
				GameCursor.isLock = false;
				Cursor.visible = true;
			}
		}

		// Token: 0x06001F93 RID: 8083 RVA: 0x000C3DA0 File Offset: 0x000C1FA0
		public void UpdateCursorLock()
		{
			if (GameCursor.isLock)
			{
				GameCursor.SetCursorPos(this.lockPos.X, this.lockPos.Y);
			}
		}

		// Token: 0x04002135 RID: 8501
		public static Vector3 pos = Vector3.zero;

		// Token: 0x04002136 RID: 8502
		public static float speed = 2000f;

		// Token: 0x04002137 RID: 8503
		public static bool isLock = false;

		// Token: 0x04002138 RID: 8504
		private GameCursor.POINT lockPos = default(GameCursor.POINT);

		// Token: 0x04002139 RID: 8505
		private bool GUICheckFlag;

		// Token: 0x0400213A RID: 8506
		private static bool mouseLocked = false;

		// Token: 0x0400213B RID: 8507
		private const int numTex = 1;

		// Token: 0x0400213C RID: 8508
		private Texture2D[] atexChange = new Texture2D[1];

		// Token: 0x0400213E RID: 8510
		private readonly string[] anameTex = new string[]
		{
			"spanking"
		};

		// Token: 0x0400213F RID: 8511
		private const int MOUSEEVENTF_LEFTDOWN = 2;

		// Token: 0x04002140 RID: 8512
		private const int MOUSEEVENTF_LEFTUP = 4;

		// Token: 0x04002141 RID: 8513
		private IntPtr windowPtr = GameCursor.GetForegroundWindow();

		// Token: 0x04002142 RID: 8514
		private GameCursor.RECT winRect = default(GameCursor.RECT);

		// Token: 0x020004D7 RID: 1239
		public enum CursorKind
		{
			// Token: 0x04002144 RID: 8516
			None = -1,
			// Token: 0x04002145 RID: 8517
			Spanking
		}

		// Token: 0x020004D8 RID: 1240
		private struct RECT
		{
			// Token: 0x04002146 RID: 8518
			public int left;

			// Token: 0x04002147 RID: 8519
			public int top;

			// Token: 0x04002148 RID: 8520
			public int right;

			// Token: 0x04002149 RID: 8521
			public int bottom;
		}

		// Token: 0x020004D9 RID: 1241
		public struct POINT
		{
			// Token: 0x06001F95 RID: 8085 RVA: 0x000C3DEC File Offset: 0x000C1FEC
			public POINT(int x, int y)
			{
				this.X = x;
				this.Y = y;
			}

			// Token: 0x0400214A RID: 8522
			public int X;

			// Token: 0x0400214B RID: 8523
			public int Y;
		}
	}
}
